home *** CD-ROM | disk | FTP | other *** search
/ The Atari Compendium / The Atari Compendium (Toad Computers) (1994).iso / files / prgtools / mint / telecomm / st52.zoo / config.c next >
Encoding:
C/C++ Source or Header  |  1991-01-21  |  1.7 KB  |  98 lines

  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <osbind.h>
  4. #include "st52.h"
  5.  
  6. char *
  7. itoa(int num, char *str, int radix)
  8. {
  9.   char format[] = "%d";
  10.  
  11.   switch (radix)
  12.   {
  13.     case 8:   format[1] = 'o';
  14.               break;
  15.     case 10:  format[1] = 'd';
  16.               break;
  17.     case 16:  format[1] = 'x';
  18.               break;
  19.   }
  20.  
  21.   sprintf(str, format, num);
  22.   return (str);
  23. }
  24.  
  25.  
  26.   
  27.  
  28. void
  29. config_bps()
  30. {
  31.   char key;
  32.   static int rates[16] = { 19200, 9600, 4800, 3600, 2400, 2000, 1800, 1200,
  33.                            600, 300, 200, 150, 130, 110, 75, 50 };
  34.   char keys[] = "0123456789abcdef";
  35.   int i;
  36.   char temp[6];
  37.  
  38.   Cconws("\n");
  39.   for (i = 0 ; i < 16 ; i++)
  40.   {
  41.     Cconws(itoa(i, temp, 16));
  42.     Cconws(":  ");
  43.     Cconws(itoa(rates[i], temp, 10));
  44.     Cconws("\n");
  45.   }
  46.   Cconws("\n");
  47.   Cconws("Choose:  ");
  48.   key = (char) (Cconin() & KEYMASK);
  49.  
  50.   for (i = 0; i < 16; i++)
  51.   {
  52.     if (keys[i] == key)
  53.     {
  54.       (void) Rsconf(i, -1, -1, -1, -1, -1);
  55.       Cconws("\nSpeed set to ");
  56.       Cconws(itoa(rates[i], temp, 10));
  57.       Cconws(" bps.");
  58.     }
  59.   }
  60.   Cconws("\n");
  61. }
  62.  
  63. void
  64. config_ucr()
  65. {
  66.   Cconws("Not implemented.\n");
  67. }
  68.  
  69. void
  70. config()
  71. {
  72.   char key;
  73.  
  74.   do
  75.   {
  76.     Cconws("\n");
  77.     Cconws("0:  exit to terminal emulator\n");
  78.     Cconws("1:  set bps rate\n");
  79.     Cconws("2:  set ucr bits (parity etc.)\n");
  80.     Cconws("\n");
  81.     Cconws("Choose:  ");
  82.  
  83.     key = (char) (Cconin() & KEYMASK);
  84.     Cconws("\n");
  85.  
  86.     switch (key)
  87.     {
  88.       case '1':  config_bps();
  89.                  break;
  90.       case '2':  config_ucr();
  91.                  break;
  92.     }
  93.   }
  94.   while (key != '0');
  95.  
  96.   
  97. }
  98.